#!/bin/bash
# Copyright 2009        Luis R. Rodriguez <mcgrof@gmail.com>
#
# Since we provide ssb, the Ethernet module b44 some people may
# rely on it to netboot, so update the initrafms for each
# distribution.
#
# Note that in the future people may want to wireless-boot
# so this will help with that as well.

LSB_RED_ID=$(/usr/bin/lsb_release -i -s)

KLIB=/lib/modules/2.6.31-wl/build
ver=$(echo $KLIB | awk -F "/lib/modules/" '{print $2}' | awk -F"/" '{print $1}')
dir=/boot/

case $LSB_RED_ID in
"Ubuntu")
	echo "Updating Ubuntu's initramfs for $ver under $dir ..."
	mkinitramfs -o $dir/initrd.img-$ver $ver
	echo "Will now run update-grub to ensure grub will find the new initramfs ..."
	update-grub
	;;
*)
	echo "Warning:"
	echo "You may or may not need to update your initframfs, you should if"
	echo "any of the modules installed are part of your initramfs. To add"
	echo "support for your distribution to do this automatically send a"
	echo "patch against $0. If your distribution does not require this"
	echo "send a patch against the '/usr/bin/lsb_release -i -s': $LSB_RED_ID"
	echo "tag for your distribution to avoid this warning."
        ;;
esac
